package com.bff.gaia.streaming.api.xjoin.core.side;
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import com.bff.gaia.api.common.typeinfo.TypeInformation;
import com.bff.gaia.api.java.typeutils.RowTypeInfo;
import com.bff.gaia.streaming.api.xjoin.core.table.TableInfo;

import java.io.Serializable;

/**
 * Description: gaia-parent
 * Created by tiger on 2019/7/18 17:08.
 */
public abstract class SideTableInfo extends TableInfo implements Serializable {

	public static final String TARGET_SUFFIX = "Side";

	public static final String CACHE_KEY = "cache";

	public static final String CACHE_SIZE_KEY = "cacheSize";

	public static final String CACHE_TTLMS_KEY = "cacheTTLMs";

	public static final String PARTITIONED_JOIN_KEY = "partitionedJoin";

	private String cacheType = "none";//None or LRU or ALL

	private int cacheSize = 10000;

	private long cacheTimeout = 60 * 1000;//

	private boolean partitionedJoin = false;

	private int asyncCapacity = 100;

	public RowTypeInfo getRowTypeInfo(){
		Class[] fieldClass = getFieldClasses();
		TypeInformation<?>[] types = new TypeInformation[fieldClass.length];
		String[] fieldNames = getFields();
		for(int i=0; i<fieldClass.length; i++){
			types[i] = TypeInformation.of(fieldClass[i]);
		}

		return new RowTypeInfo(types, fieldNames);
	}

	public String getCacheType() {
		return cacheType;
	}

	public void setCacheType(String cacheType) {
		this.cacheType = cacheType;
	}

	public int getCacheSize() {
		return cacheSize;
	}

	public void setCacheSize(int cacheSize) {
		this.cacheSize = cacheSize;
	}

	public long getCacheTimeout() {
		return cacheTimeout;
	}

	public void setCacheTimeout(long cacheTimeout) {
		this.cacheTimeout = cacheTimeout;
	}

	public boolean isPartitionedJoin() {
		return partitionedJoin;
	}

	public void setPartitionedJoin(boolean partitionedJoin) {
		this.partitionedJoin = partitionedJoin;
	}

	public int getAsyncCapacity() {
		return asyncCapacity;
	}

	public void setAsyncCapacity(int asyncCapacity) {
		this.asyncCapacity = asyncCapacity;
	}
}